<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展 
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------

namespace app\admin\model\wddj\operation;

use think\Model;


class StartingPrice extends Model
{

    

    

    // 表名
    protected $name = 'wddj_starting_price';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    

    protected static function init()
    {
        self::beforeInsert(function ($row) {
            $row->end_time = $row->end_time.':59';
        });
        self::beforeUpdate(function ($row) {
            $row->end_time = $row->end_time.':59';
        });
        self::afterInsert(function ($row) {
            if (!$row['weigh']) {
                $pk = $row->getPk();
                $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
            }
        });
    }

    protected function getStartTimeAttr($value)
    {
        return substr($value,0,5);
    }

    protected function getEndTimeAttr($value)
    {
        return substr($value,0,5);
    }



    public function vehicle()
    {
        return $this->belongsTo('app\common\model\Category', 'vehicle_type', 'id', [], 'LEFT')->setEagerlyType(0);
    }





}
